﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Infrastructure.Interfaces;
using D.Medicalcare.Read.API.Application.Command.DoctorCommand;
using MediatR;

namespace D.Medicalcare.Read.API.Application.Handler.DoctorHander
{
    public class FtDoctorHarder : IRequestHandler<FtDoctorCommand, APIResult<Doctor>>
    {

        private readonly IBaseRepository<Doctor> repository;

        public FtDoctorHarder(IBaseRepository<Doctor> repository)
        {
            this.repository = repository;
        }

        public Task<APIResult<Doctor>> Handle(FtDoctorCommand request, CancellationToken cancellationToken)
        {
            APIResult<Doctor> result = new APIResult<Doctor>();
            result.Code = APIEnum.Mvc;
            result.Msg = "查询成功";
            var list = repository.GetAll().Where(x=>x.DoctorId== request.DoctorId).First();
            result.Data = list;

            return Task.FromResult(result);
        }
    }
}
